package com.glepoch.springbootsecuritymybatis.mappper.menu;

import com.glepoch.springbootsecuritymybatis.bean.Menu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface MenuMapper {
    @Select("select * from menu where `type` in (1,2) order by morder ")
    List<Menu> findAllMenu();

    List<Menu> selectMenuPage(Menu menu);
    @Select("select " +
            "  m.* " +
            " from " +
            "  menu m " +
            " left join menu_role mr on " +
            "  m.id = mr.mid " +
            " left join user_role ur on " +
            "  mr.rid = ur.rid " +
            " where " +
            "  ur.uid =#{userId,jdbcType=DECIMAL} or m.type=0 order by morder ")
    List<Menu> selectMenuByUserId(Long userId);
}
